@extends('layouts.app')
@section('content')
<div class="container" style="width: 100%">
    <div class="row">
        <div class="col-md-12 col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">线路列表</div>
                <div class="panel-body table-responsive">
                    <div>

                        <form name="fm_order" action="{{route('admin.line')}}" class="form-inline" method="get">
                           <!--  姓名/电话：
                            <input type="text" name="key" class="form-control" value="{{Request::input('key')}}">
                            <button type="submit" class="btn btn-primary">查询</button> -->
                            <a href="{{route('admin.line.add')}}" class="btn btn-primary">
                                <i class="glyphicon glyphicon-plus"></i>添加
                            </a>

                        </form>
                    </div>
                    <table class="table ">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>起点</th>
                                <th>终点</th>
                                <th>票价</th>
                                
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($list as $item)
                            <tr>
                                <td>{{$item->id}}</td>
                                <td>{{$item->start}}</td>
                                <td>{{$item->end}}</td>
                                <td>{{$item->price}}</td>                                
                                <td>
                                    <a href="{{route('admin.line.edit',['id'=>$item->id])}}">
                                        编辑
                                    </a>&nbsp;
                                    
                                </td>
                            </tr>
                            @endforeach
                        </tbody>
                    </table>
                    <div>
                        {{  $list->appends([
                                'status'=>Request::input('status'),
                                'date'=>Request::input('date'),
                                'code'=>Request::input('code')
                            ])->links()
                        }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
@section('js')
<script>
    function do_query() {
        $('form[name="fm_order"]')[0].submit();
    }

    $(function(){
    
        $('input[name="date"]').daterangepicker({
            // "startDate": "2017-01-01",
            // "endDate": moment().format("YYYY-MM-DD"),
            "ranges": {
                "今天": [
                    moment().format("YYYY/MM/DD"),
                    moment().format("YYYY/MM/DD")
                ],
                "昨天": [
                    moment().add(-1, 'days').format("YYYY/MM/DD"),
                    moment().add(-1, 'days').format("YYYY/MM/DD")
                ],
                "上周": [
                    moment().add(-6, 'days').format("YYYY/MM/DD"),
                    moment().format("YYYY/MM/DD")
                ],
                "30天前": [
                    moment().add(-29, 'days').format("YYYY/MM/DD"),
                    moment().format("YYYY/MM/DD")
                ],
                "本月": [
                    moment().startOf('month').format('YYYY-MM-DD'),
                    moment().endOf('month').format('YYYY-MM-DD')
                ],
                "上个月": [
                    moment().add(-1,'M').startOf('month').format('YYYY-MM-DD'),
                    moment().add(-1,'M').endOf('month').format('YYYY-MM-DD')
                ]
            },
            "locale": {
               "format": "YYYY/MM/DD",
               "separator": " - ",
               "applyLabel": "确定",
               "cancelLabel": "取消",
               "fromLabel": "从",
               "toLabel": "至",
               "customRangeLabel": "自定义",
               "weekLabel": "星期",
               "daysOfWeek": [
                   "日",
                   "一",
                   "二",
                   "三",
                   "四",
                   "五",
                   "六"
               ],
               "monthNames": [
                   "1月",
                   "2月",
                   "3月",
                   "4月",
                   "5月",
                   "6月",
                   "7月",
                   "8月",
                   "9月",
                   "10月",
                   "11月",
                   "12月"
               ],
               "firstDay": 1
           },           
        }, function(start, end, label) {
          console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
        });


    });
</script>
@endsection